<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			//获取并更新用户基本信息，在用户授权手机号后使用本接口
			getUserInfo() {
				let vm = uni.getStorageSync('UserInfo');
				if (!vm || !vm.token) {
					uni.navigateTo({
						url: '/pages/login/index'
					})
				}
			},
			//完善用户信息
			updateUserInfo() {
				let vm = uni.getStorageSync('UserInfo');
				if (vm.user.avatarUrl != null && vm.user.nickName != '微信用户') {
					uni.navigateTo({
						url: '/pagesA/user/userinfo'
					})
					return;
				}
				uni.getUserProfile({
					desc: '用于完善用户信息',
					success: (res) => {
						uni.$u.http.post('/Customer/UploadUserInfo', res.userInfo).then(data => {});
						vm.user.nickName = res.userInfo.nickName;
						vm.user.avatarUrl = res.userInfo.avatarUrl;
						vm.user.gender = res.userInfo.gender;
						vm.user.country = res.userInfo.country;
						vm.user.province = res.userInfo.province;
						vm.user.city = res.userInfo.city;
						vm.user.language = res.userInfo.language;
						uni.setStorage({
							key: "UserInfo",
							data: vm
						});
						uni.navigateTo({
							url: '/pagesA/user/userinfo'
						})
					},
					fail: (err) => {
						console.log(err)
					}
				});
			}
		}
	}
</script>

<style>
	/*每个页面公共css */
	/* @import 'animate.css'; */
	@import '/static/animate.css';
</style>
<style lang="scss">
	@import "static/icon/iconfont.css";
	@import "colorui/main.css";
	@import "colorui/icon.css";
	@import "@/uni_modules/uview-ui/index.scss";


	//page {
	//	background: #F6F7F8;
	//}
</style>
